﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;

namespace KSTools.Controls
{
    public partial class MenuPanel : UserControl
    {
        public Form mdiParent { get; set; }

        public MenuPanel()
        {
            InitializeComponent();
        }

        private void toolStripButtonClose_Click(object sender, EventArgs e)
        {
            Hide();
        }

        public void Show()
        {
            this.Dock = DockStyle.Left;
            mdiParent.Controls.Add(this);
            mdiParent.Controls.SetChildIndex(this, 1);
            this.Visible = true;
            LoadToolList();
        }

        private void LoadToolList()
        {
            NavigationPanePanel navigationPaneBigMenu = new NavigationPanePanel();
            ButtonItem buttonItemBigMenu = new ButtonItem();
            navigationPaneMenu.Controls.Add(navigationPaneBigMenu);
            navigationPaneMenu.Items.Add(buttonItemBigMenu);
            navigationPaneBigMenu.AntiAlias = true;
            navigationPaneBigMenu.Dock = DockStyle.Fill;
            navigationPaneBigMenu.Location = new Point(0, 0);
            navigationPaneBigMenu.Name = "工具列表";
            navigationPaneBigMenu.Padding = new Padding(1, 1, 1, 0);
            navigationPaneBigMenu.ParentItem = buttonItemBigMenu;
            navigationPaneBigMenu.Size = new Size(188, 493);
            navigationPaneBigMenu.Style.Alignment = StringAlignment.Center;
            navigationPaneBigMenu.Style.BackColor1.ColorSchemePart = eColorSchemePart.BarBackground;
            navigationPaneBigMenu.Style.BackColor2.ColorSchemePart = eColorSchemePart.BarBackground2;
            navigationPaneBigMenu.Style.BackgroundImagePosition = eBackgroundImagePosition.Tile;
            navigationPaneBigMenu.Style.Border = eBorderType.SingleLine;
            navigationPaneBigMenu.Style.BorderColor.ColorSchemePart = eColorSchemePart.PanelBorder;
            navigationPaneBigMenu.Style.ForeColor.ColorSchemePart = eColorSchemePart.ItemText;
            navigationPaneBigMenu.Style.GradientAngle = 90;
            buttonItemBigMenu.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.ImageAndText;
            //buttonItemBigMenu.Image = imageListTree.Images[pic_name];
            buttonItemBigMenu.Name = "buttonItem" + "工具列表";
            buttonItemBigMenu.OptionGroup = "navBar";
            buttonItemBigMenu.Text = "工具列表";
            buttonItemBigMenu.Tooltip = "工具列表";
            TreeView treeViewFuncs = new TreeView();
            navigationPaneBigMenu.Controls.Add(treeViewFuncs);
            treeViewFuncs.ContextMenu = new ContextMenu();
            treeViewFuncs.Dock = DockStyle.Fill;
            treeViewFuncs.Location = new System.Drawing.Point(1, 1);
            treeViewFuncs.Name = "treeView" + "工具列表";
            treeViewFuncs.Size = new Size(186, 434);
            treeViewFuncs.ItemHeight = 19;
            treeViewFuncs.HideSelection = false;
            treeViewFuncs.ImageList = imageList;

            TreeNode tnList = new TreeNode();
            tnList.Text = "测试1";
            tnList.ImageKey = "dir";
            tnList.SelectedImageKey = "dir";

            treeViewFuncs.Nodes.Add(tnList);

        }

        /// <summary>
        /// 隐藏界面
        /// </summary>
        public new void Hide()
        {
            if (mdiParent != null)
            {
                mdiParent.Controls.Remove(this);
                //FuncPanel = null;
            }
        }
    }
}
